package com.techstar.api.service.city;

import java.io.FileReader;
import java.io.Reader;
import java.util.List;

import org.joda.time.DateTime;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.techstar.api.pojo.city.DistrictCongestTrend;
import com.techstar.common.jackson.JacksonMapper;

/**
 * 
 * @author EinIce
 * @description 1.1、行政区拥堵趋势
 * @date 2021年6月25日
 *
 */
@Service
public class DistrictCongestTrendService {
	
	private static final ObjectMapper objectMapper = JacksonMapper.instance.objectMapper;
	
	
	public void query(){
		try {
			Reader reader = new FileReader("F:\\WORKING\\交委\\数据样例\\1.1、行政区拥堵趋势.json");
			int ch = reader.read();
			StringBuffer buffer = new StringBuffer();
			while (ch != -1) { // 读取成功
				buffer.append((char) ch);
				ch = reader.read();
			}
//			System.out.println(buffer.toString());
			// 3、关闭流
			reader.close();
			String result = buffer.toString();
			JsonNode jsonNode = JacksonMapper.instance.objectMapper.readTree(result).get("data");
			List<DistrictCongestTrend> readValue= objectMapper.readValue(jsonNode.toString(), new TypeReference<List<DistrictCongestTrend>>() {});
//			readValue.forEach(p->System.out.println(Integer.valueOf((int) p.getCreateTime().getMillis())));
//			readValue.forEach(p->System.out.println(p.getCreateTime().getMillis()));
			System.out.println(readValue.toString());
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		System.out.println(DateTime.now().getMillis());
	}
}
